package loader.parser.adapter;

import java.util.Date;
import java.util.HashMap;

public class Adapter455Tuan extends SiteAdapter {

	private static HashMap<String, String> maps = new HashMap<String, String>();
	static {
		maps.put("id", "oid");
		maps.put("title", "title");
		maps.put("deal_url", "dealUrl");

		maps.put("small_image_url", "sImageUrl");
		maps.put("medium_image_url", "mImageUrl");
		maps.put("large_image_url", "lImageUrl");
		maps.put("deal_desc", "dealDesc");
		maps.put("quantity_sold", "salesNum");
		maps.put("division_name", "cityName");

		maps.put("price", "price");
		maps.put("value", "dealValue");
		maps.put("discount_percent", "discountPercent");

		maps.put("start_date", "startTime");
		maps.put("end_date", "endTime");

		maps.put("vendors", "shops");

		maps.put("vendor_name", "shopName");
		maps.put("site_url", "shopUrl");
		maps.put("phone", "shopPhone");
		maps.put("address", "shopAddress");
		maps.put("district", "shopArea");
		maps.put("lng", "longtitude");
		maps.put("lat", "latitude");
		/** division **/
		maps.put("did", "pyName");
		maps.put("dname", "name");
		maps.put("dtimezone", "timezone");
		maps.put("dtimezone_offset_gmt", "timezone_offset_gmt");
		maps.put("dlatitude", "latitude");
		maps.put("dlongitude", "longtitude");
	}

	public String getProperName(String oName) {
		return maps.get(oName.trim());
	}

	@Override
	public String getFullUrl(String city) {
		return "http://www.55tuan.com/openAPI.do?city=" + city;
	}

	@Override
	public String getCitiesUrl() {
		return "http://www.55tuan.com/city.xml";
	}

	@Override
	public String getFileDir() {
		Date d = new Date();
		return "C://wowotuan/" + d.getTime() + ".xml";
	}

	@Override
	public boolean isNewDeal(String nodeName) {
		return nodeName.trim().equals("deal");
	}

	@Override
	public boolean isNewCity(String nodeName) {
		return nodeName.trim().equals("division");
	}

	@Override
	public boolean isNewShop(String nodeName) {
		return nodeName.trim().equals("vendor_name");
	}

	@Override
	public String getSiteName() {
		return "wowotuan";
	}
}
